package cn.laixueit.mapper;

import cn.laixueit.pojo.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface StudentMapper {


    @Select("select * from student")
    public List<Student> list();

    @Select("select * from student")
    @Results(
            id = "studentMap",
            value = {
                    @Result(property = "id",column = "id",id = true),
                    @Result(property = "name",column = "name"),
                    @Result(property = "address",column = "address"),
                    @Result(property = "teacher",column = "id",one = @One(select = "cn.laixueit.mapper.TeacherMapper.findBySid"))
            }
    )
    List<Student> findStudentOneToManyTeacher();

    @Select("select * from student")
    @Results(
            id = "studentMap2",
            value = {
                    @Result(property = "id",column = "id",id = true),
                    @Result(property = "name",column = "name"),
                    @Result(property = "address",column = "address"),
                    @Result(property = "teachers" ,column = "id",many = @Many(select = "cn.laixueit.mapper.TeacherMapper.findBySid"))
            }
    )
    public List<Student> findStudentOneToManyTeacher2();

    public List<Student> findStudentOneToManyTeacher3();


}
